using System.Diagnostics;
using System.IO;
using System.Net;
using System.Xml;

namespace Catchbase.Service.API
{
    public class HttpWebResponseGateway : IStreamProvider
    {
        private readonly HttpWebResponse _response;

        protected HttpWebResponseGateway()
        {
        }

        public HttpWebResponseGateway(HttpWebResponse response)
        {
            Debug.Assert(response != null);
            _response = response;
        }

        public virtual HttpStatusCode StatusCode
        {
            get { return _response.StatusCode; }
        }

        #region IStreamProvider Members

        public Stream GetStream()
        {
            return _response.GetResponseStream();
        }

        public void ReleaseStream(Stream stream)
        {
            Debug.Assert(stream != null);
            stream.Close();
        }

        #endregion
    }
}